<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>
<script type="text/javascript" src="/admins/js/jquery/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="/admins/js/jquery/jquery.PrintArea.js"></script>
</head>
<body>
<!-- Home -->
<div data-role="page" id="page1">
    <div data-theme="a" data-role="header">        
        <a data-role="button" href="javascript:goback();" class="ui-btn-left">
            返回
        </a>
        <h3>
            扫描出库
        </h3>
    </div>
        <div data-role="fieldcontain">
            <input id="brcode" name="brcode" placeholder="请输入包裹条形码" type="text">
        </div>
        <div id="res"></div>
       
</div>

<script type="text/javascript">
 function showfocus(){
    $("#brcode").val("");
    $("#brcode").focus();
 }
 $("#brcode").focus();
$(document).ready(function(){ 
 $('#brcode').focus().keyup(function(e){
      if(e.keyCode === 13){
         var brcode = $("#brcode").val();
         var barcode=$("#brcode").val();
            $.ajax({    
                type: 'POST',
                url: '/admini/Managestore/checkbarcode?barcode='+barcode,
                success: function(data) {
                    if(data.type === 1){
                        showmp3(brcode);
                        setTimeout("showfocus()",1000);
                        $('#res').html("<font size='5' color='green'>" + barcode + "成功扫描出库</font>");
                    }else if(data.type === 100){
                        showmp3(brcode);
                        setTimeout("showfocus()",1000); 
                        setTimeout("showpicking()",1000); 
                    }else if(data.type === 2){
                        $('#res').html("<font size='5' color='red'>" + barcode + "无此包裹信息</font>"); 
                        scanerr();
                    }
                }
            });
     }
 }).blur(function(){
     $('#brcode').focus();
 });
 });


 function showmp3(brcode){
    $("#divi"+brcode).css("background","#B9F789");
    var audio = document.createElement('audio');
    audio.src = '/images/storage/success.mp3?rnd'+Math.random();//这里放音乐的地址
    audio.autoplay = 'autoplay';
    document.body.appendChild(audio);
}

function scanerr(){
    var audio = document.createElement('audio');
    audio.src = '/images/storage/xuxushishi.mp3?rnd'+Math.random();
    audio.autoplay = 'autoplay';
    document.body.appendChild(audio);
    setTimeout("showfocus()",1000);
}

function goback(){
    location.href='/admini/managelogin/tabletlist';
}

</script>
</body>
</html>